package com.qidian.mes.md.controller;

import com.qidian.mes.md.service.MdUnitMeasureService;
import com.qidian.mes.pojo.MdUnitMeasure;
import com.qidian.mes.util.pojo.MESResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author 32郗建狄
 * @Company GX631
 * Time 2023/10/28 9:53
 * Description
 */
@RestController
@RequestMapping("/measure")
@CrossOrigin
public class MdUnitMeasureController {
    @Autowired
    private MdUnitMeasureService mdUnitMeasureService;

    /**
     * 获取所有的单位 用于在新增物料的弹窗中选择单位
     * @return
     */
    @GetMapping("/getAllMeasure")
    public MESResult getAllMeasure(){
        return mdUnitMeasureService.getAllMeasure();
    }

    /**
     * 添加单位
     * @param mdUnitMeasure
     * @return
     */
    @PostMapping("/save")
    public MESResult save(@RequestBody MdUnitMeasure mdUnitMeasure){
        return mdUnitMeasureService.save(mdUnitMeasure);
    }
    @DeleteMapping("/delete")
    public MESResult delete(Long measureId){
        return mdUnitMeasureService.delete(measureId);
    }
    @DeleteMapping("/deletes")
    public MESResult deletes(Long[] measureId){
        return mdUnitMeasureService.deletes(measureId);
    }

    /**
     * 多条件分页查询单位
     * @param page
     * @param limit
     * @param mdUnitMeasure
     * @return
     */
    @GetMapping("/list")
    public MESResult list(@RequestParam(defaultValue = "1") int page,@RequestParam(defaultValue = "10") int limit,MdUnitMeasure mdUnitMeasure){
//        System.out.println("111111111111111111111111111");
//        System.out.println(mdUnitMeasure);
        return mdUnitMeasureService.list(page, limit, mdUnitMeasure);
    }
    @GetMapping("/get")
    public MESResult get(Long measureId){
        return mdUnitMeasureService.get(measureId);
    }
    @PutMapping("/update")
    public MESResult update(@RequestBody MdUnitMeasure mdUnitMeasure){
        return mdUnitMeasureService.update(mdUnitMeasure);
    }
}
